package gx.illness.controller;

import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import gx.JsonResult;
import gx.illness.entity.Illness;
import gx.illness.service.IllnessService;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("illness")
@Api(value = "Illness",description = "入口 针对病情等级划分操作表")
public class IllnessController {

	@Autowired
	private IllnessService illnessService;
	
	// 创建线程安全的Map
	static Map<String, Illness> users = Collections.synchronizedMap(new HashMap<String, Illness>());
	
	// log4j日志输出
	private Logger logger = LoggerFactory.getLogger(this.getClass());
	
	/**
	 * 查询用户列表
	 * @return
	 */
	@ApiOperation(value="获取疼痛等级划分列表", notes="获取疼痛等级划分列表")
	@RequestMapping(value = "illnesses", method = RequestMethod.GET)
	public ResponseEntity<JsonResult> getIllnessList (){
		JsonResult r = new JsonResult();
		try {  
			List<Illness> illnessList = illnessService.getIllnessList();
			r.setResult(illnessList);
			r.setStatus("ok");
		} catch (Exception e) {
			r.setResult(e.getClass().getName() + ":" + e.getMessage());
			r.setStatus("error");
			e.printStackTrace();
		}
		return ResponseEntity.ok(r);
	}
	
	/**
	 * 
		{	
			"uuid": "swagger",
			"login_name": "swagger",
			"login_password": "swagger111",
			"nick_name": "nick_name",
			"status": 1,
			"add_time": "add_time",
			"remark": "remark"
		}
	 */
}
